﻿using Common.Authentication;
using Common.Dto;
using Demo03.Config.Properties;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Demo03.Controller;

/// <summary>
/// test 接口
/// </summary>
[ApiController]
[Route("test")]
[Authorize(AuthenticationSchemes = AppJwtBearerDefaults.AuthenticationScheme)]
public class TestController : ControllerBase
{
    private readonly ProjectProperties _properties;
    private readonly AseKeyProperties _aseKeyProperties;

    public TestController(ProjectProperties properties, AseKeyProperties aseKeyProperties)
    {
        _properties = properties;
        _aseKeyProperties = aseKeyProperties;
    }

    /// <summary>
    /// ping 测试
    /// </summary>
    /// <returns></returns>
    [HttpGet("ping")]
    public Result<string> Ping()
    {
        return Result.Success("pong");
    }

    /// <summary>
    /// 项目配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("project-properties")]
    public Result<ProjectProperties> ProjectProperties()
    {
        return Result.Success(_properties);
    }
    
    /// <summary>
    /// aes密码配置
    /// </summary>
    /// <returns></returns>
    [HttpGet("aes-properties")]
    public Result<AseKeyProperties> AesProperties()
    {
        return Result.Success(_aseKeyProperties);
    }
}